﻿using UnityEngine;
namespace HBFramework
{
    public partial class AudioManager
    {
        private AudioPlayer bgmPlayer;

        public AudioPlayer PlayBgm(AudioClip audioClip, float volume)
        {
            if (bgmPlayer != null)
            {
                StopPlayer(bgmPlayer);
            }
            bgmPlayer = PlayMusic(audioClip, volume);
            return bgmPlayer;
        }

        public AudioPlayer PlayBgm(string key, float volume)
        {
            if (!audioClipDict.ContainsKey(key))
            {
                Debug.LogError($"音频 {key} 未加载");
                return null;
            }
            return PlayBgm(audioClipDict[key], volume);
        }
    }
}